<?php

namespace app\api\controller;

use app\admin\model\Gamefps;
use app\common\controller\Api;

class Game extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];


    public function fps()
    {
        $type = input('type',0);
        $cpu_id = input('cpu_id',0);
        $xianka_id = input('xianka_id',0);
        $page_num = input('page_num',10);
        $keyword = input('keyword','');

        $where = [];
        if ($keyword){
            $where['name'] = ['like', '%' . $keyword . '%'];
        }

        $list = \app\admin\model\Game::where($where)->order('weigh desc')
            ->paginate($page_num, false, ['query' => request()->get()]);
        foreach ($list as $k=>$v){
            $gamefps = Gamefps::get(['cpu_id'=>$cpu_id,'xianka_id'=>$xianka_id,'type'=>$type]);

            $list[$k]['fps_id'] = $gamefps ? $gamefps->id : '';
            $list[$k]['fps'] = $gamefps ? $gamefps->fps : 0;
            $list[$k]['min_fps'] = $gamefps ? $gamefps->min_fps : 0;
            $list[$k]['max_fps'] = $gamefps ? $gamefps->max_fps : 0;
            $list[$k]['dram_size'] = $gamefps ? $gamefps->dram_size : 0;
            $list[$k]['gpu_mem_size'] = $gamefps ? $gamefps->gpu_mem_size : 0;
        }
        $this->success('请求成功',$list);
    }
}